﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using Ajax.IDAL;
using Ajax.Model;

namespace Ajax.FactoryDAL
{
    public class DataAccess
    {
        //读取配置文件，对应的数据库访问层包名！
        private static readonly string path = ConfigurationManager.AppSettings["FactoryKey"].ToString();

        public static IAdbanner CreateAdbanner()
        {
            string classname = path + ".Adbanner";
            return (IAdbanner)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }

        public static IAdministrator CreateAdministrator()
        {
            string classname = path + ".Admin";
            return (IAdministrator)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }

        public static IAdvertising CreateAdvertising()
        {
            string classname = path + ".Advertising";
            return (IAdvertising)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }

        public static IArticle CreateArticle()
        {
            string classname = path + ".Article";
            return (IArticle)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }

        public static IChannel CreateChannel()
        {
            string classname = path + ".Channel";
            return (IChannel)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }

        public static IContents CreateContents()
        {
            string classname = path + ".Contents";
            return (IContents)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }

        public static IFeedback CreateFeedback()
        {
            string classname = path + ".Feedback";
            return (IFeedback)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }

        public static ILinks CreateLinks()
        {
            string classname = path + ".Links";
            return (ILinks)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }

        public static IProducts CreateProducts()
        {
            string classname = path + ".Products";
            return (IProducts)System.Reflection.Assembly.Load(path).CreateInstance(classname);
        }
    }
}
